package com.chukun.netty.mempool;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.PooledByteBufAllocator;

/**
 * @author chukun
 *  netty 内存池分析
 */
public class NettyMemoryPoolAnalyse {


    public static void main(String[] args) {
        ByteBufAllocator allocator = PooledByteBufAllocator.DEFAULT;

        //tiny规格内存分配 会变成大于等于16的整数倍的数：这里254 会规格化为256
        ByteBuf buf = allocator.directBuffer(254);

        // 读写byteBuf
        buf.writeInt(123);

        allocator.directBuffer(254);

        System.out.println(buf.readInt());

        // 内存释放
        buf.release();

    }
}
